package com.etc.zmall.service.impl;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.etc.dao.OrdersDao;
import com.etc.dao.impl.OrdersDaoImpl;
import com.etc.dto.OrderCountDto;
import com.etc.entity.Orders;
import com.etc.util.PageData;
import com.etc.zmall.service.OrdersService;

/**
 * 
 * <p>
 * Title: OrdersServiceImpl
 * </p>
 * 
 * <p>
 * Description:
 * </p>
 * 
 * @author knowno
 * 
 * @date 2021年1月16日
 * 
 */
public class OrdersServiceImpl implements OrdersService {

	private OrdersDao orderdao = new OrdersDaoImpl();

	/**
	 * (non-Javadoc)
	 * 
	 * <p>
	 * Title: addOrder
	 * </p>
	 * 
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param orders
	 * @return
	 * 
	 * @see com.etc.zmall.service.OrdersService#addOrder(com.etc.zmall.entity.Orders)
	 * 
	 */
	@Override
	public boolean addOrder(Orders orders) {
		// TODO Auto-generated method stub
		return orderdao.addOrder(orders);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * <p>
	 * Title: upOrdersState
	 * </p>
	 * 
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param orderstate
	 * @param orderid
	 * @return
	 * 
	 * @see com.etc.zmall.service.OrdersService#upOrdersState(int, java.lang.String)
	 * 
	 */
	@Override
	public boolean upOrdersState(int orderstate, String orderid) {
		// TODO Auto-generated method stub
		return orderdao.upOrdersState(orderstate, orderid);
	}

	/**
	 * (non-Javadoc)
	 * 
	 * <p>
	 * Title: getByPage
	 * </p>
	 * 
	 * <p>
	 * Description:
	 * </p>
	 * 
	 * @param keywords
	 * @param begindate
	 * @param enddate
	 * @param pageNo
	 * @param pageSize
	 * @return
	 * 
	 * @see com.etc.zmall.service.OrdersService#getByPage(java.lang.String,
	 *      java.lang.String, java.lang.String, int, int)
	 * 
	 */
	@Override
	public PageData<Orders> getByPage(String keywords, String begindate, String enddate, int pageNo, int pageSize) {
		if ("".equals(begindate)) {
			begindate = "2020-01-01";
		}
		if ("".equals(enddate)) {
			enddate = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
		}

		return orderdao.getByPage(keywords, begindate, enddate, pageNo, pageSize);
	}

	
	@Override
	public List<OrderCountDto> getOrderCount() {
		// TODO Auto-generated method stub
		return orderdao.getOrderCount();
	}
	
}
